﻿package com.moa;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.htmlparser.MyParse62;
import com.pc.util.http.PCHttp;

@SuppressWarnings("serial")
public class GetURLServlet extends HttpServlet
{
	public static String name="";
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException
	{
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException{
		
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		DataOutputStream dos = new DataOutputStream(baos);
		String linkUrl = request.getParameter("linkUrl");
		System.out.println("linkUrl"+linkUrl);
		
		String inputHtml = "";//PCHttp.sendGet(name,null,linkUrl);
		
		try {
			String result = MyParse62.getContent(inputHtml,"", true);
			result ="true"  + result;
			dos.writeUTF(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		

//		if ("../show/read_notify.php?NOTIFY_ID=33".equals(linkUrl)){
//			
//			String msg = "true" + "http://61.236.244.30:3006/MOA/result2.jsp";
//			dos.writeUTF(msg);
//		}else{
//			dos.writeUTF("false");
//		}
		
		byte[] data = baos.toByteArray();
		response.setStatus(HttpServletResponse.SC_OK);
		response.setContentLength(data.length);
		response.setContentType("text/plain;charset=UTF-8"); 
		OutputStream os = response.getOutputStream();
		os.write(data);
		os.close();
	}

}
